//
//  CuttingPhotos.cpp
//  BayMaxPuzzle
//
//  Created by Jacky on 15/3/28.
//
//

#ifndef __BayMaxPuzzle__CuttingPhotos__
#define __BayMaxPuzzle__CuttingPhotos__

#include <stdio.h>
#include <vector>
#include "cocos2d.h"

USING_NS_CC;

class CuttingPhotos:public Layer
{
    
    CuttingPhotos();
    ~CuttingPhotos();
    
public:
    static CuttingPhotos* create(std::string photo,unsigned int rows=3,unsigned int columns=3);
    bool checkIsWin();
    void restart();
    void restartGame();
    inline void setEnabled(bool isenabled){_isEnabled = isenabled;}
    
protected:
    
    unsigned int _rows;//row
    unsigned int _columns;//column
    unsigned int _sliceWidth;//slice width
    unsigned int _sliceHeight;//slice height
    
    std::vector<std::vector<Sprite*>> _slices;
    
    bool _isTouching;
    bool _isEnabled;
    
    virtual bool initWithPhoto(std::string photo,unsigned int rows,unsigned int columns);
    
    bool initSlice(std::string photo);
    
    void initTouchEventlistener();
    
    void move(int row,int col);
    
};

#endif /* defined(__BayMaxPuzzle__CuttingPhotos__) */